package bavaria.hightec.testit;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;


import bavaria.hightec.banking.BankImpl;
import bavaria.hightec.banking.BankRegistry;
import bavaria.hightec.banking.Currency;
import bavaria.hightec.banking.Money;
import bavaria.hightec.conditions.Conditions.runtime;
import bavaria.hightec.exceptions.OverCheckException;
import bavaria.hightec.exceptions.UnknownLanguageException;



public class UnitTest {
	
	BankImpl bankrl = new BankImpl("Bierbank","EN");
	BankImpl bank2 = new BankImpl("Amenbank","DE");
	BankRegistry bankreg = BankRegistry.getInstance();
	
	
	
	private Money money1;
	private Money money2;
	private Money money3;
	private Money money4;
	private Money money5;
	private Money money6;
	

@Before
public void setUp() throws Exception {
	money1 = new Money(10, Currency.CHF);
	money2 = new Money(20, Currency.EUR);
	money3 = new Money(30, Currency.USD);
	money4 = new Money(40, Currency.GBP);
	money5 = new Money(50, Currency.RUB);
	money6 = new Money(50000, Currency.EUR);
	bankreg.bind("Bierbank", bankrl);
	bankreg.bind("Amenbank", bank2);
	bankrl.createDepositAccount("Test1", runtime.SIX);
	bank2.createGiroAccount("Test");
	bankrl.fund(1000, money2, "TestTransaktion");
	bank2.fund(1000, money6, "TestGeld");
}


@After
public void tearDown() throws Exception {
	money1=null;
	money2=null;
	money3=null;
	money4=null;
	money5=null;
}

@Test
public void testtransaktion() throws OverCheckException{
	bankreg.lookup("Amenbank").transaction("Bierbank", 1000, 1000, money2, "Transaktion");
	assertEquals(bank2.balance(1000),49980);
	assertEquals(bankrl.balance(1000),40);
	
}

@Test //exchangeRateList={0.76,0.69,1.13,0.025};//CHF,USD,GBP,RUB
public void testaddition(){
		assertEquals(money2.addition(money1.getAmount(), money1.getCurrency()),new Money(27,Currency.EUR).getAmount());
	

}

@Test //exchangeRateList={0.76,0.69,1.13,0.025};//CHF,USD,GBP,RUB
public void testaddition2(){
        assertEquals(money2.addition(money2.getAmount(), money2.getCurrency()),new Money(40,Currency.EUR).getAmount());
}

@Test //exchangeRateList={0.76,0.69,1.13,0.025};//CHF,USD,GBP,RUB
public void testaddition3(){
        assertEquals(money2.addition(money3.getAmount(), money3.getCurrency()),new Money(40,Currency.EUR).getAmount());
}

@Test //exchangeRateList={0.76,0.69,1.13,0.025};//CHF,USD,GBP,RUB
public void testaddition4(){
        assertEquals(money2.addition(money4.getAmount(), money4.getCurrency()),new Money(65,Currency.EUR).getAmount());
}

@Test //exchangeRateList={0.76,0.69,1.13,0.025};//CHF,USD,GBP,RUB
public void testaddition5(){
        assertEquals(money2.addition(money5.getAmount(), money5.getCurrency()),new Money(21,Currency.EUR).getAmount());
}



//@Test
//public void testFund() throws OverCheckException{
//	bank.fund(1000, money1, "dicht");
//	assertEquals(bank.balance(1000),7);
//	
//	bank.fund(1001, money2, "dicht");
//	assertEquals(bank.balance(1001),20);
//	
//	bank.fund(1002, money3, "dicht");
//	assertEquals(bank.balance(1002),20);
//	
//	bank.fund(1003, money4, "dicht");
//	assertEquals(bank.balance(1003),45);
//	
//	bank.fund(1004, money5, "dicht");
//	assertEquals(bank.balance(1004),1);
//	
//}
//
//@Test(expected=OverCheckException .class)
//public void testWithdrawDeposit() throws OverCheckException{
//	bank.withdraw(1001, money1, "muha");
//	bank.withdraw(1003, money3, "jetz erst recht");
//}
//
//@Test(expected=OverCheckException .class)
//public void testWithdrawGiro() throws OverCheckException{
//	bank.withdraw(1000, money6, "so nicht");
//}
//
//@Test
//public void testTransaktion() throws OverCheckException{
//	bank.transaction(1000, 1001, money1, "bla");
//	assertEquals(bank.balance(1000),-7);
//	assertEquals(bank.balance(1001),7);
//}
//
//@Test(expected=UnknownAccountException .class)
//public void testTransaktionException() throws OverCheckException{
//	bank.transaction(1000, 1300, money1, "is egal was");
//}
//
//@Test(expected=MaximumAccountException .class)
//public void testMaxAccountException(){
//	while(true)
//	bank.createDepositAccount("Mustermann, Max",runtime.THREE);
//    
//}

}
